﻿#region license
//Copyright 2008 Ritesh Rao 

//Licensed under the Apache License, Version 2.0 (the "License"); 
//you may not use this file except in compliance with the License. 
//You may obtain a copy of the License at 

//http://www.apache.org/licenses/LICENSE-2.0 

//Unless required by applicable law or agreed to in writing, software 
//distributed under the License is distributed on an "AS IS" BASIS, 
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
//See the License for the specific language governing permissions and 
//limitations under the License. 
#endregion

namespace Rhinestone.Domain
{
    /// <summary>
    /// Attachment entry associated with a <see cref="WorkItem"/> instance.
    /// </summary>
    public class Attachment
    {
        #region fields
        private int _attachmentID;
        private string _fileName;
        private AttachmentFile _file;
        private WorkItem _workItem;
        #endregion

        #region .ctor
        /// <summary>
        /// Inherited Constructor.
        /// Creates a new instance of the <see cref="Attachment"/> class.
        /// </summary>
        protected Attachment() {}

        /// <summary>
        /// Default Constructor.
        /// Creates a new instance of the <see cref="Attachment"/> class with
        /// the specified class name and <see cref="AttachmentFile"/>
        /// </summary>
        /// <param name="fileName">string. The name of the attachment.</param>
        /// <param name="file">An <see cref="AttachmentFile"/> instance containing the contents
        /// of the attachment.</param>
        public Attachment(string fileName, AttachmentFile file)
        {
            _fileName = fileName;
            _file = file;
        }
        #endregion

        #region properties
        /// <summary>
        /// Gets the unique ID assigned to the attachment.
        /// </summary>
        /// <value>int. The unique ID assigned to the attachment.</value>
        public virtual int AttachmentID
        {
            get { return _attachmentID; }
        }

        /// <summary>
        /// Gets the name of the attachment file.
        /// </summary>
        /// <value>string. The name of the attachment file.</value>
        public virtual string FileName
        {
            get { return _fileName; }
        }

        /// <summary>
        /// Gets or sets summary information about the attachment.
        /// </summary>
        /// <value>string. Summary information about the attachment.</value>
        public virtual string Summary { get; set; }

        /// <summary>
        /// Gets the <see cref="WorkItem"/> instance containing this <see cref="Attachment"/>
        /// instnace. 
        /// </summary>
        /// <value>The <see cref="WorkItem"/> that contains this attachment.</value>
        public virtual WorkItem WorkItem
        {
            get { return _workItem; }
            internal set { _workItem = value; }
        }

        /// <summary>
        /// Gets the <see cref="AttachmentFile"/> instance containing the contents of the attachment.
        /// </summary>
        /// <value>The <see cref="AttachmentFile"/> instance containing the contents of the attachment.</value>
        public virtual AttachmentFile File
        {
            get { return _file; }
        } 
        #endregion
    }
}
